package com.sreader.sreader4j;

import java.io.Serializable;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

public class Messages implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final String BUNDLE_NAME_BASE = "com.sreader.resources";
	//private static final String BUNDLE_NAME = "com.sreader.resources.messages"; //$NON-NLS-1$
	private  String bundleName;
	private  ResourceBundle resourceBundle;
	
	//private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
		//	.getBundle(BUNDLE_NAME);

	public Messages(String propertiesFileName, Locale locale) {
		bundleName = BUNDLE_NAME_BASE + "." + propertiesFileName ;
		resourceBundle = ResourceBundle.getBundle(bundleName, locale);
	}

	public  String getString(String key) {
		try {
			return resourceBundle.getString(key);
		} catch (MissingResourceException e) {
			return '!' + key + '!';
		}
	}
}
